home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / UTIL / TouchMe 1.1.1.sit / touchMe 1.11 Folder / CW9 PP source / source / Common / UErrorMessage.cp < prev    next >
Text File  |  1996-08-08  |  2KB  |  89 lines

  1. // ==================================================
  2. //    UErrorMessage.cp
  3. //    Copyright (C) 1994-96 Mizutori Tetsuya, March 9 1994, July 4 1996.
  4. // ==================================================
  5. //    All documents are pretty-printed in Geneva 10-point font.
  6.  
  7. #include <Resources.h>
  8. #include <Memory.h>
  9. #include <TextUtils.h>
  10. #include <Dialogs.h>
  11. #include <SegLoad.h>
  12. #include <Processes.h>
  13. #include <Notification.h>
  14. #include <Errors.h>
  15.  
  16. #include <UDesktop.h>
  17.  
  18. #include "UErrorMessage.h"
  19.  
  20. #define        kErrorMessage_ResType        'ErrM'
  21.  
  22. const ResIDT    ALRT_ErrorBox                = 9000;
  23.  
  24.  
  25. // --------------------------------------------------
  26. //        ・ NofityIfOSErr
  27. // --------------------------------------------------
  28.  
  29. void
  30. UErrorMessage::NofityIfOSErr(
  31.     const OSErr    inErr,
  32.     const Boolean    inBeFatal )
  33. {
  34.     NofityIfOSErr( inErr, "¥p", inBeFatal );
  35. }
  36.  
  37.  
  38. // --------------------------------------------------
  39. //        ・ NofityIfOSErr
  40. // --------------------------------------------------
  41.  
  42. void
  43. UErrorMessage::NofityIfOSErr(
  44.     const OSErr    inErr,
  45.     const Str255    inText,
  46.     const Boolean    inBeFatal )
  47. {
  48.  
  49.     if ( inErr == noErr ) return;
  50.  
  51.     Str31    theErrNumber;
  52.     Str255    theResName;
  53.     Str255    theErrMessage;
  54.     Handle    theResourceH;
  55.  
  56.     theResourceH = ::GetResource( kErrorMessage_ResType, (short) inErr );
  57.     if ( theResourceH != nil ) {
  58.         short        theID;
  59.         ResType    theType;
  60.         ::GetResInfo( theResourceH, &theID, &theType, theResName );
  61.         theErrMessage[0] = ::GetHandleSize( theResourceH );
  62.         ::BlockMoveData( (Ptr) *theResourceH, &theErrMessage[0], theErrMessage[0] );
  63.         ::ReleaseResource( theResourceH );
  64.     } else {
  65.         theResName[0] = 0;
  66.         theErrMessage[0] = 0;
  67.     }
  68.  
  69.     ::NumToString( inErr, theErrNumber );
  70.  
  71.     ::ParamText( theResName, theErrNumber, theErrMessage, inText );
  72.  
  73.     // Deactivate the desktop.
  74.     UDesktop::Deactivate();
  75.  
  76.     if ( inBeFatal ) {
  77.         ::StopAlert( ALRT_ErrorBox, nil );
  78.         ::ExitToShell();
  79.     } else {
  80.         ::NoteAlert( ALRT_ErrorBox, nil );
  81.     }
  82.  
  83.     // Activate the desktop.
  84.     UDesktop::Activate();
  85. }
  86.  
  87.  
  88. // end of program
  89.